var _tools = require("../../../utils/tools.js"), _tools2 = _interopRequireDefault(_tools);

function _interopRequireDefault(t) {
    return t && t.__esModule ? t : {
        default: t
    };
}

var that, WxParse = require("../../wxParse/wxParse.js"), app = getApp();

Page({
    data: {
        indicatorDots: !1,
        vertical: !1,
        autoplay: !0,
        interval: 5e3,
        duration: 1e3,
        isScrollY: !0,
        current: 0,
        isIphoneX: !1,
        text: "立即购买",
        show: !1,
        s_index: 0,
        number: 1,
        source: 1,
        request: 1
    },
    onLoad: function(t) {
        that = this, t.id && (this.data.id = t.id);
    },
    swiperchange: function(t) {
        this.setData({
            current: t.detail.current
        });
    },
    onReady: function() {
        wx.getSystemInfo({
            success: function(t) {
                if ("ios" == t.platform) {
                    that.setData({
                        isIphone: !0
                    });
                    -1 < t.model.indexOf("iPhone X") && that.setData({
                        isIphoneX: !0
                    });
                }
            }
        }), wx.setNavigationBarColor({
            frontColor: "#000000",
            backgroundColor: "#000000"
        });
    },
    onShow: function() {
        var t = {
            action: "details",
            contr: "goods",
            id: this.data.id,
            token: wx.getStorageSync("token")
        };
        _tools2.default.request(t, function(t) {
            that.setData(t.info);
            var a = t.info.details.details;
            WxParse.wxParse("article", "html", a, that, 5);
        });
    },
    onHide: function() {},
    handleTap: function() {
        this.data.my_bargain ? wx.navigateTo({
            url: "/bh_bargain/pages/bargain/bargain?id=" + this.data.my_bargain.id
        }) : this.launch();
    },
    launch: function(t) {
        if (1 == this.data.request) {
            this.data.request = 2;
            var a = {
                action: "launch",
                contr: "help",
                token: wx.getStorageSync("token"),
                goods_id: this.data.id
            };
            _tools2.default.request(a, function(t) {
                that.data.request = 1, 2 == t.status ? wx.showModal({
                    title: "提示",
                    mask: !0,
                    content: t.info,
                    showCancel: !1
                }) : wx.reLaunch({
                    url: "/bh_bargain/pages/bargain/bargain?id=" + t.info.id
                });
            });
        }
    },
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {
        return {
            title: this.data.share.text,
            imageUrl: this.data.share.images,
            path: "bh_bargain/pages/index/index?parent_id=" + this.data.share.member_id
        };
    },
    getUserInfo: function(t) {
        if ("getUserInfo:ok" == t.detail.errMsg) {
            var a = {
                action: "register",
                contr: "my",
                token: wx.getStorageSync("token"),
                encryptedData: t.detail.encryptedData,
                iv: t.detail.iv
            };
            _tools2.default.request(a, function(t) {
                that.handleTap();
            });
        }
    }
});